// pages/index/index.js
let a = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isListData: !0,
    currentSwiper: 0,
    indicatorDots: 0,
    autoplay: !0,
    interval: 4e3,
    duration: 1e3,
    imgSource:[
      {
        url:'https://www.vpwyu.com/data/gallery_album/original_img/5951c2be2a806.jpg',
        link:'/packageA/pages/seckill/index'
      }
    ]
  },

  swiperChange (e){
    this.setData({
      currentSwiper: e.detail.current
    })
  },

  toCategory:function(e){
    let that = this;
    let cat_id = String(e.currentTarget.dataset.cat_id);
    wx.setStorageSync("cat_id", cat_id);
    wx.switchTab({
      url: '../category/index',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let ru_id = a.globalData.ru_id;
    let that = this;
      wx.request({
        url: a.apiUrl("store/detail2"),
        data: {
          id: ru_id,
          ru_id:ru_id,
          page: 1,
          per_page: 6,
          cate_key: "is_on_sale",
          sort: "sort_order",
          order: "ASC",
          cat_id: 50
        },
        header: {
          "Content-Type": "application/json"
        },
        method: "POST",
        success: function (t) {
          that.setData({
            goods_one: t.data.goods
          })
          wx.setStorage({
            key: "shop_name",
            data: t.data.detail.rz_shopName
          });
        }
      });
      wx.request({
        url: a.apiUrl("store/detail2"),
        data: {
          id: ru_id,
          ru_id:ru_id,
          page: 1,
          per_page: 4,
          cate_key: "is_on_sale",
          sort: "sort_order",
          order: "ASC",
          cat_id: 51
        },
        header: {
          "Content-Type": "application/json"
        },
        method: "POST",
        success: function (t) {
          that.setData({
            goods_two: t.data.goods
          })
        }
      });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})